<?php
class My_Cache
{
    public static $lifetime      = 86400;
    public static $serialization = true;
    public static $cacheDir      = '../data/cache';

    protected static $_cache;

    public static function getCache($name) {
        return self::_cache()->load($name);
    }

    public static function saveCache($data, $name, $tags=array()) {
        self::_cache()->save($data, $name, $tags);
    }

    public static function clearCache($name) {
        self::_cache()->remove($name);
    }

    public static function cleanTagCache(array $tags) {        
        self::_cache()->clean(            
            Zend_Cache::CLEANING_MODE_ALL            
        );        
    }

    protected static function _cache() {
        if (self::$_cache === null) {
            self::$_cache = Zend_Cache::factory(
                'Core',
                'File',
                array(
                    'lifetime'                => self::$lifetime,
                    'automatic_serialization' => self::$serialization
                ),
                array(
                    'cache_dir' => self::$cacheDir
                )
            );          
        }
        return self::$_cache;
    }
}